﻿using System;
using System.IO;
using System.Runtime.InteropServices;

namespace MatlabBridge.NativeMethods
{
    internal static class libmat
    {
        [DllImport("libmat.dll", CharSet = CharSet.Ansi)]
        public static extern IntPtr matOpen(string filename, string mode);
        [DllImport("libmat.dll")]
        public static extern int matClose(IntPtr mfp);

        //char **matGetDir(MATFile *mfp, int *num);
        [DllImport("libmat.dll")]
        public static unsafe extern IntPtr matGetDir(IntPtr mfp, int* num);
        [DllImport("libmat.dll")]
        public static extern IntPtr matGetFp(IntPtr mfp);

        [DllImport("libmat.dll", CharSet = CharSet.Ansi)]
        public static unsafe extern IntPtr matGetNextVariable(IntPtr mfp, string[] name);
        [DllImport("libmat.dll", CharSet = CharSet.Ansi)]
        public static unsafe extern IntPtr matGetNextVariableInfo(IntPtr mfp, string[] name);
        [DllImport("libmat.dll")]
        public static extern IntPtr matGetVariable(IntPtr mfp, string name);
        [DllImport("libmat.dll")]
        public static extern IntPtr matGetVariableInfo(IntPtr mfp, string name);

        [DllImport("libmat.dll")]
        public static extern int matPutVariable(IntPtr mfp, string name, IntPtr pm);
        [DllImport("libmat.dll")]
        public static extern int matPutVariableAsGlobal(IntPtr mfp, string name, IntPtr pm);
        [DllImport("libmat.dll")]
        public static extern int matDeleteVariable(IntPtr mfp, string name);
    }
}
